<template>
  <div class="page">
    <h1>Home - {{ count }}</h1>
  </div>
</template>

<script>
export default {
  data() {
    return {
      count: 1,
    };
  },

  // 激活
  activated() {
    console.log("Home activated");
    this.timer = setInterval(() => {
      this.count++;
    }, 1000);
  },

  // 失活
  deactivated() {
    console.log("Home deactivated");
    // 收尾
    clearInterval(this.timer);
  },
};
</script>
